package com.ru.application.creditscore.context;

import java.util.HashMap;
import javax.servlet.*;
import org.apache.log4j.Logger;
import com.ru.application.creditscore.util.Constant;

public class Initializer implements ServletContextListener {
  private final static Logger logger = Logger.getLogger(Initializer.class);
  public final static String TOOLBAR = "toolBar";
  private HashMap<String,String> toolBar = new HashMap<String,String>(); 
  
  public Initializer() {
  
  }

  public void contextInitialized(ServletContextEvent event)  {
    ServletContext servletContext = event.getServletContext();
    logger.info("Initializing CreditScore...");
    toolBar.put(Constant.SCHEMA, Constant.HOME);
    toolBar.put(Constant.SCHEMA, Constant.SCHEMA);
    toolBar.put(Constant.FACTOR, Constant.FACTOR);
    servletContext.setAttribute(TOOLBAR, toolBar);
    logger.info("Initialization complete...");
  }

  public void contextDestroyed(ServletContextEvent event) {
      logger.info("Context destroying...");
      event.getServletContext().removeAttribute(TOOLBAR);
      logger.info("Context destroying completely...");
  }
}
